package com.ruoyi.system.api.domain.caigou;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.system.api.domain.SysDept;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.domain.basedata.Supplies;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 采购退货单对象 finer_buy_back_order
 *
 * @author wl
 * @date 2024-10-25
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BuyBackOrder implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
    private Integer id;
    private Integer isStockOut;
    /**
     * 采购退货编码
     */
    @Excel(name = "采购退货编码")
    private String buyBackOrderCode;

    /**
     * 入库单id（源单号）
     */
    @Excel(name = "入库单id", readConverterExp = "源=单号")
    private Integer stockInId;

    //采购退货申请单id
    @Excel(name = "采购退货申请单id")
    private Integer buyBackReqId;

    //采购退货申请单对象
    private BuyBackReq buyBackReq;

    /**
     * 供应商id
     */
    @Excel(name = "供应商id")
    private Integer supplierId;

    //供应商对象
    private Supplies supplier;

    //供应商名称
    @Excel(name = "供应商名称")
    private String supName;

    /**
     * 采购订单id
     */
    @Excel(name = "采购订单id")
    private Integer buyOrderId;

    //采购入库单编号
    @Excel(name = "采购入库单编号")
    private String stockInCode;

    /**
     * 总出库数量
     */
    @Excel(name = "总出库数量")
    private Integer allOutStock;

    /**
     * 实际出库数量
     */
    @Excel(name = "实际出库数量")
    private Integer realOutStock;

    /**
     * 总收款
     */
    @Excel(name = "总收款")
    private BigDecimal allInPrice;

    /**
     * 实际收款
     */
    @Excel(name = "实际收款")
    private BigDecimal realInPrice;

    /**
     * 入库状态（0：无1：等待2：部分3：完全）
     */
    @Excel(name = "入库状态", readConverterExp = "0=：无1：等待2：部分3：完全")
    private Integer stockStatus;

    @Excel(name = "入库状态")
    private String stockStatusName;

    /**
     * 收款状态（0：无1：等待2：部分3：完全）
     */
    @Excel(name = "收款状态", readConverterExp = "0=：无1：等待2：部分3：完全")
    private Integer payStatus;

    @Excel(name = "收款状态")
    private String payStatusName;

    /**
     * 单据日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "单据日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date orderDate;

    /**
     * 部门id
     */
    @Excel(name = "业务部门id")
    private Integer srcDeptId;

    //业务部门对象
    private SysDept srcDept;

    //业务部门
    @Excel(name = "业务部门")
    private String srcDeptName;

    /**
     * 用户id
     */
    @Excel(name = "业务员id")
    private Integer srcUserId;

    //业务员对象
    private SysUser srcUser;

    //业务员
    @Excel(name = "业务员")
    private String srcUserName;

    /**
     * 单据阶段（1：已编制2：已提交3：已审批4：执行完）
     */
    private Integer orderStatus;

    @Excel(name = "单据阶段")
    private String orderStatusName;

    /**
     * 审批结果（0：无1：未审批2：已通过3：已驳回）
     */
    private Integer approvalResult;

    //审核意见
    @Excel(name = "审核意见")
    private String approvalOption;

    //审核人id
    @Excel(name = "审核人id")
    private Integer approvalId;

    //审核人对象
    private SysUser approvalUser;

    //审核人名称
    @Excel(name = "审核人名称")
    private String approvalName;

    /**
     * 是否生效（0：未生效1：已生效）
     */
    private Integer isEffect;

    /**
     * 是否关闭（0：未关闭1：已关闭）
     */
    private Integer isClose;

    /**
     * 是否作废（0：未作废1：已作废）
     */
    private Integer isCancel;

    /**
     * 审批结果名称
     */
    @Excel(name = "审批结果")
    private String approvalResultName;

    /**
     * 是否生效名称
     */
    @Excel(name = "是否生效")
    private String isEffectName;

    /**
     * 是否关闭名称
     */
    @Excel(name = "是否关闭")
    private String isCloseName;

    /**
     * 是否作废名称
     */
    @Excel(name = "是否作废")
    private String isCancelName;

    /**
     * 生效时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "生效时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date effectDate;

    //创建人
    private String createBy;
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date createDate;

    /**
     * 修改人
     */
    @Excel(name = "修改人")
    private String modifyBy;

    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date modifyDate;

    /**
     * 是否删除（0：未删除1：已删除）
     */
    private Integer isDel;

    //备注
    @Excel(name = "备注")
    private String remark;

    /**
     * 采购退货单明细
     */
    private List<BuyBackOrderDetail> buyBackOrderDetailList;

    /**
     * 搜索值
     */
    @JsonIgnore
    private String searchValue;


    /**
     * 请求参数
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Map<String, Object> params;

    public Map<String, Object> getParams() {
        if (params == null) {
            params = new HashMap<>();
        }
        return params;
    }

    public void setParams(Map<String, Object> params) {
        this.params = params;
    }

    public void setApprovalResult(Integer approvalResult) {
        this.approvalResult = approvalResult;
        if (approvalResult == null) {
            return;
        } else if (approvalResult == 0) {
            this.approvalResultName = "无";
        } else if (approvalResult == 1) {
            this.approvalResultName = "未审批";
        } else if (approvalResult == 2) {
            this.approvalResultName = "审核通过";
        } else if (approvalResult == 3) {
            this.approvalResultName = "审核未通过";
        }
    }

    public void setIsEffect(Integer isEffect) {
        this.isEffect = isEffect;
        if (isEffect == null) {
            return;
        } else if (isEffect == 0) {
            this.isEffectName = "未生效";
        } else if (isEffect == 1) {
            this.isEffectName = "已生效";
        }
    }

    public void setIsClose(Integer isClose) {
        this.isClose = isClose;
        if (isClose == null) {
            return;
        } else if (isClose == 0) {
            this.isCloseName = "未关闭";
        } else if (isClose == 1) {
            this.isCloseName = "已关闭";
        }
    }

    public void setIsCancel(Integer isCancel) {
        this.isCancel = isCancel;
        if (isCancel == null) {
            return;
        } else if (isCancel == 0) {
            this.isCancelName = "未作废";
        } else if (isCancel == 1) {
            this.isCancelName = "已取消";
        }
    }

    public void setStockStatus(Integer stockStatus) {
        this.stockStatus = stockStatus;
        if (stockStatus == null) {
            return;
        } else if (stockStatus == 0) {
            this.stockStatusName = "无";
        } else if (stockStatus == 1) {
            this.stockStatusName = "待出库";
        } else if (stockStatus == 2) {
            this.stockStatusName = "部分出库";
        } else if (stockStatus == 3) {
            this.stockStatusName = "全部出库";
        }
    }

    public void setPayStatus(Integer payStatus) {
        this.payStatus = payStatus;
        if (payStatus == null) {
            return;
        } else if (payStatus == 0) {
            this.payStatusName = "无";
        } else if (payStatus == 1) {
            this.payStatusName = "待收款";
        } else if (payStatus == 2) {
            this.payStatusName = "部分收款";
        } else if (payStatus == 3) {
            this.payStatusName = "全部收款";
        }
    }

    public void setOrderStatus(Integer orderStatus) {
        this.orderStatus = orderStatus;
        if (orderStatus == null) {
            return;
        } else if (orderStatus == 1) {
            this.orderStatusName = "编辑中";
        } else if (orderStatus == 2) {
            this.orderStatusName = "已提交";
        } else if (orderStatus == 3) {
            this.orderStatusName = "执行中";
        } else if (orderStatus == 4) {
            this.orderStatusName = "已完成";
        }
    }
}
